package vg.com.classdata;

import vg.com.frame.img_1_3.httpBitmapRequestDelegate;

import com.kdstudio.network.URLCachePolicy;
import com.kdstudio.network.URLRequest;
import com.kdstudio.network.URLRequestDelegate;
import com.kdstudio.network.reponse.URLBitmapResponse;

import android.os.Handler;
import android.widget.ImageView;

public class yahoo {

	private String status;
	private String url_img;
	private String name;
	ImageView img;
	private int iconRes;
	Handler mhHandler;
	// private SampleAdapter adapter;
	// adapter_Friend adapter;
	private Handler mHanlder;

	public yahoo(String status, String name, String url, int iconRes) {

		this.status = status;
		this.name = name;
		this.url_img = url;
		this.iconRes = iconRes;
		// adapter.notifyDataSetChanged();

	}

	public ImageView getImg() {
		return img;
	}

	public void setImg(ImageView img) {
		this.img = img;
	}

	public int getIconRes() {
		return iconRes;
	}

	public void setIconRes(int iconRes) {
		this.iconRes = iconRes;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUrl_img() {
		return url_img;
	}

	public yahoo() {
		super();
	}

	public void setUrl_img(String url_img) {
		this.url_img = url_img;
	}

	public void loadImage(String url) {
		mHanlder = new Handler();
		// khoi tao request gui lenh den server
		URLRequest request = new URLRequest(url,
				new httpBitmapRequestDelegate());
		// gui va lay theo kieu gi(Json hay BitMap)
		request.setReponse(new URLBitmapResponse());
		// set che do cache cua request
		request.setCachePolicy(URLCachePolicy.LOCAL);
		request.send();
	}

	public class httpBitmapRequestDelegate extends URLRequestDelegate {
		public void onRequestReponse(URLRequest httpRequest) {
			// TODO Auto-generated method stub
			// kieu can response(Json hay BitMap)
			final URLBitmapResponse response = (URLBitmapResponse) httpRequest
					.getReponse();
			mHanlder.post(new Runnable() {

				public void run() {
					// TODO Auto-generated method stub
					// set anh
					getImg().setImageBitmap(response.bitmap);
				}
			});

			super.onRequestReponse(httpRequest);
		}
	}
}
